﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using DAL;

namespace _14期Razor引擎
{
    /// <summary>
    /// add 的摘要说明
    /// </summary>
    public class add : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";

            if (context.Request["title"]!=null)
            {
                //不是第一次请求
                string title = context.Request["title"];
              
                int i= SqlHelper.ExecteNonQueryText("insert into myclass values (@classname)", new SqlParameter("@classname",title)
                );
                if (i>0)
                {
                    context.Response.Redirect("listRazor.ashx");
                }
            }
            RazorHelper.Render("add.html",null,new RazorHelper.IncludeType()
            {
                Title = "Top",
                Content = "Top.html",
                IsFile = true
            });
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}